<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    =={{msg}}==={{count}}==={{obj.num}}
    <hr />
  普通: <button @click="count++">++</button>
   深度:<button @click="add">++</button>
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: 'hello  vue',
        count:10,
        obj:{
          num:1
        }
      },
      methods: {
        add(){
          this.obj.num++
        }
      },
      watch:{
        count(newval,oldcal){
          console.log(newval,oldcal)
          
          
        },
        // 'obj.num'(){
        //   console.log(2222)
          
        // },
        //深度监视
        obj:{
            deep:true,//深度监视
            immediate:true,//立即监听
            handler(newval){
              console.log(newval.num,999)
              
            }
          }
      }
    })

    
  </script>
</body>

</html>